package com.bkfm.framework.core.service;

import java.util.List;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import com.bkfm.framework.core.api.service.IBkfmTableMetaServer;
import com.bkfm.framework.core.utils.ExecuteCall;
import com.bkfm.framework.core.utils.QueryCall;

/**
 * jsp页面调用数据库底层的实现方法
 * @平台：统一开发平台
 * @文件名称：BlkModelServiceUtils.java
 * @文件描述：
 * @author xuqiang
 * @日期：2018年7月16日上午9:32:18
 *
 */
public class BkfmModelServiceUtils {

	private static final WebApplicationContext context;
	
	private static final IBkfmTableMetaServer bkfmModelService;
	
	static {
		context = ContextLoader.getCurrentWebApplicationContext();
		bkfmModelService = context.getBean(BkfmTableMetaServer.class);
	}
	
	/**
	 * 查询sql
	 * @param sql
	 * @param queryCall 回调函数，返回查询的结果集List<ResultSet>
	 * @throws Exception
	 */
	public static void queryResultBySql(String sql,QueryCall queryCall) throws Exception{
		bkfmModelService.queryResultBySql(sql, queryCall);
	}
	
	/**
	 * 执行更新sql语句
	 * @param sql
	 * @return
	 * @throws Exception
	 */
	public static void executeSql(String sql,ExecuteCall executeCall)throws Exception{
		bkfmModelService.executeSql(sql, executeCall);
	}
	
	/**
	 * 批量执行sql
	 * @param sql
	 * @throws Exception
	 */
	public static void executeBatchSql(List<String> sql,ExecuteCall executeCall)throws Exception{
		bkfmModelService.executeBatchSql(sql, executeCall);
	}
	
	/**
	 * 执行存储过程，返回执行的查询结果
	 * @param procName
	 * @param params
	 * @param queryCall 返回对象
	 * @throws Exception
	 */
	/*public static void queryProc(String procName,List<BlkProcParam> params,QueryCall queryCall)throws Exception{
		blkModelBaseService.queryResultByProc(procName, params, queryCall);
	}*/
	
	/**
	 * 执行存储过程
	 * @param procName
	 * @param params
	 * @param executeCall
	 * @throws Exception
	 */
	/*public static void executeProc(String procName,List<BlkProcParam> params,ExecuteCall executeCall)throws Exception{
		blkModelBaseService.executeProc(procName, params, executeCall);
	}*/
}
